function RunAlready = APEsplash(varargin)
% APESPLASH MATLAB code for APEsplash.fig
%      APESPLASH, by itself, creates a new APESPLASH or raises the existing
%      singleton*.
%
%      H = APESPLASH returns the handle to a new APESPLASH or the handle to
%      the existing singleton*.
%
%      APESPLASH('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in APESPLASH.M with the given input arguments.
%
%      APESPLASH('Property','Value',...) creates a new APESPLASH or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before APEsplash_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to APEsplash_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help APEsplash

% Last Modified by GUIDE v2.5 13-Apr-2012 19:01:46

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @APEsplash_OpeningFcn, ...
                   'gui_OutputFcn',  @APEsplash_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before APEsplash is made visible.
function APEsplash_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to APEsplash (see VARARGIN)

%% check if run before

try 
    x=evalin('base','APERunSplash');
catch
    APERunSplash = true;
    assignin('base','APERunSplash',APERunSplash);
    x = false;
end    
if x == true
%     disp('Schon gerunned')
    close(gcf)
    return
end

%% code
handles.output = hObject;

handles.axes1
imshow('APElogoV1_midi_white.png')
if size(varargin,2) == 0
    time2show   = 5;            % standard value
else
    try
        time2show   = ceil(varargin{1});
    catch ME      
        ME;
    end
end
newPosition = 0;
for i=1:time2show
    uiwait(gcf,1)
    newPosition = newPosition + (1/time2show);
    set(handles.slider1,'Value',newPosition)
end
uiwait(gcf,1)
close(gcf)
return

% Update handles structure
guidata(hObject, handles);



% --- Outputs from this function are returned to the command line.
function varargout = APEsplash_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
% varargout{1} = handles.output;


function slider1_Callback(hObject, eventdata, handles)


function slider1_CreateFcn(hObject, eventdata, handles)

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end
